|
In the C and C++ programming languages, an #include guard, sometimes called a macro guard, is a particular construct used to avoid the problem of ''double inclusion'' when dealing with the include directive. The addition of #include guards to a header file is one way to make that file idempotent. ==Double inclusion== The following C code demonstrates a real problem that can arise if #include guards are missing: ;File "grandfather.h" ;File "father.h" ;File "child.c" Here, the file "child.c" has indirectly included two copies of the text in the header file "grandfather.h". This causes a compilation error, since the structure type foo will thus be defined twice. In C++, this would be a violation of the One Definition Rule.抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Include guard」の詳細全文を読む スポンサード リンク
|